﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace conti.maurizio._4BI.DataFile
{

    public class DataPoint
    {

        public double X { get; set; }
        public double Y { get; set; }

        public DataPoint(XElement e)
        {
            double tmp = 0;
            Double.TryParse(e.Attribute("x").Value, out tmp);
            X = tmp;

            tmp = 0;
            Double.TryParse(e.Attribute("y").Value, out tmp);
            Y = tmp;
        }
    }

    public class DataFile : List<DataPoint>
    {
        public DataFile(string nomeFile)
        {

            XElement xml = XElement.Load(nomeFile);

            var punti = from XElement e in xml.Elements("data")
                        select new DataPoint(e);

            this.AddRange(punti);
        }
    }
}
